package com.asdhawaii.otello.players;

import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import com.asdhawaii.otello.board.Move;
import com.asdhawaii.otello.board.Square;
import com.asdhawaii.otello.board.SquareContents;

/**
 * Tests the Level 4 AI.
 * 
 * @author Branden Ogata
 *
 */

public class TestLevel4Ai extends TestAbstractOtelloAi
{
  /**
   * Tests that the Level 4 AI behaves as expected.
   * 
   */
  
  @Test
  public void test()
  {
    Level4Ai ai = new Level4Ai(SquareContents.BLACK);
    Square[][] board = createEmptyBoard();
    List<Move> validMoves = new ArrayList<Move>();
    
    board[1][1].setContents(SquareContents.WHITE);
    board[2][2].setContents(SquareContents.BLACK);
    board[3][3].setContents(SquareContents.WHITE);
    board[6][7].setContents(SquareContents.WHITE);
    board[7][7].setContents(SquareContents.BLACK);
    
    TestAbstractOtelloAi.createList(validMoves, new Move(0, 0), new Move(4, 4), new Move(5, 7));
    
    // Should play the corner first
    assertEquals("Plays corner move", new Move(0, 0), ai.getMove(board, validMoves));
    
    // After that, plays a stable move
    board[0][0].setContents(SquareContents.BLACK);
    board[1][1].setContents(SquareContents.BLACK);
    validMoves.remove(new Move(0, 0));
    assertEquals("Plays stable move", new Move(5, 7), ai.getMove(board, validMoves));
    
    // The remaining behavior is identical to Level3Ai, so will not need to test here
  }
}